package com.icow.wms.basic.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.icow.common.annotation.Log;
import com.icow.common.core.controller.BaseController;
import com.icow.common.core.domain.AjaxResult;
import com.icow.common.enums.BusinessType;
import com.icow.wms.basic.domain.SsxPeripheral;
import com.icow.wms.basic.service.ISsxPeripheralService;
import com.icow.common.utils.poi.ExcelUtil;
import com.icow.common.core.page.TableDataInfo;

/**
 * ssxController
 *
 * @author bcs
 * @date 2024-08-08
 */
@RestController
@RequestMapping("/peripheral/ssx")
public class SsxPeripheralController extends BaseController {
    @Autowired
    private ISsxPeripheralService ssxPeripheralService;

    /**
     * 查询ssx列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SsxPeripheral ssxPeripheral) {
        startPage();
        List<SsxPeripheral> list = ssxPeripheralService.selectSsxPeripheralList(ssxPeripheral);
        return getDataTable(list);
    }

    /**
     * 导出ssx列表
     */
    @Log(title = "ssx", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SsxPeripheral ssxPeripheral) {
        List<SsxPeripheral> list = ssxPeripheralService.selectSsxPeripheralList(ssxPeripheral);
        ExcelUtil<SsxPeripheral> util = new ExcelUtil<SsxPeripheral>(SsxPeripheral.class);
        return util.exportExcel(list, "peripheral");
    }

    /**
     * 获取ssx详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(ssxPeripheralService.selectSsxPeripheralById(id));
    }

    /**
     * 新增ssx
     */
    @Log(title = "ssx", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SsxPeripheral ssxPeripheral) {
        return toAjax(ssxPeripheralService.insertSsxPeripheral(ssxPeripheral));
    }

    /**
     * 修改ssx
     */
    @Log(title = "ssx", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SsxPeripheral ssxPeripheral) {
        return toAjax(ssxPeripheralService.updateSsxPeripheral(ssxPeripheral));
    }

    /**
     * 删除ssx
     */
    @Log(title = "ssx", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ssxPeripheralService.deleteSsxPeripheralByIds(ids));
    }
}